package club.hicode.daydayup.abc.support;

import java.util.concurrent.locks.LockSupport;

/**
 * 说话者
 * @author Liu Chunfu
 * @date 2018-08-23 下午8:29
 **/
public class Seaker extends Thread {

	private String key;

	private Thread next;

	public Seaker(String key, Thread next) {
		this.key = key;
		this.next = next;
	}

	public Seaker(String key) {
		this.key = key;
	}


	@Override
	public void run() {
		while (true) {
			System.out.print(key + "-");
			LockSupport.unpark(next);
			LockSupport.park();
		}
	}

	public void setNext(Thread next) {
		this.next = next;
	}
}
